package code08_常用类.可变字符串;

/**
 * @author 黄衡熙
 * @version 1.0
 */
public class Test02_常用方法 {
    public static void main(String[] args) {
        // StringBuffer与StringBuilder两者用法完全一致
        StringBuffer buffer = new StringBuffer();
        buffer.append("Hello ")
                .append("World");
        System.out.println(buffer);
        // 在索引位置3之前插入指定子字符串admin
        buffer.insert(3,"admin");
        System.out.println(buffer);
        // 删除索引位置[3,8)的字符
        buffer.delete(3,8);
        System.out.println(buffer);
        // 删除指定索引位置5的字符
        buffer.deleteCharAt(5);
        System.out.println(buffer);
        buffer.reverse();
        System.out.println(buffer);
        System.out.println("------------------");
        String s = buffer.toString();
        System.out.println(s);
        System.out.println(buffer.length());
        System.out.println(buffer.substring(0,5));
    }
}
